package com.besttone.adapter;

import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.besttone.search.R;
import com.besttone.search.model.City;
import com.besttone.search.util.SharedUtils;
import com.besttone.search.util.StringUtils;

import java.util.ArrayList;

public class CityListAdapter extends LetterListAdapter {
	public CityListAdapter() {
	}

	public CityListAdapter(Context paramContext, ArrayList<City> paramArrayList) {
		super(paramContext, paramArrayList);
	}

	public View setTheView(int paramInt, View paramView,
			ViewGroup paramViewGroup) {
		City localCity = (City) this.mCitylist.get(paramInt);
		if ("-1".equals(localCity.getCityName())) {
			TextView localTextView = new TextView(this.mContext);
			localTextView.setTextAppearance(this.mContext, R.style.text_18_black);
			localTextView.setPadding(15, 0, 0, 0);
			localTextView.setBackgroundResource(R.color.title_grey);
			localTextView.setGravity(16);
			localTextView.setText(localCity.getFirstLetter());
			return localTextView;
		}
		View localView = LayoutInflater.from(this.mContext).inflate(R.layout.select_city_list_item,
				null);
		String str1 = localCity.getCityName();
		((TextView) localView.findViewById(R.id.city_info)).setText(str1);
		ImageView localImageView = (ImageView) localView.findViewById(R.id.selected_item);
		String str2 = SharedUtils.getCurrentCityName(this.mContext);
		if ((!StringUtils.isEmpty(str2)) && (str2.equals(str1))) {
			localImageView.setVisibility(View.VISIBLE);
		} else {
			while (true) {
				localImageView.setVisibility(View.INVISIBLE);
				break;
			}
		}
		return localView;
	}
}
